package org.eden.rpc.service.dao;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;
import org.eden.rpc.common.entity.dao.User;

import java.util.List;

public interface UserMapper {

    @Select("select * from user")
    List<User> getAllUsers();

    // 插入一条新的用户记录，并且将自增主键设置到user中
    @Insert("insert into user(username, password, email, phone, authority_ids, valid, `delete`, reg_time) " +
            "values(#{username}, #{password}, #{email}, #{phone}, #{authority}, #{valid}, #{delete}, #{regTime})")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    int insert(User user);

    @Select("select * from user where id=#{id}")
    User getById(Long id);
}
